				<form id="listForm" name="listForm" method="post" action="">
					<table class="table">
						<tr class="subject">
							<td width="5%" class="checkBoxTd">选择</td>
							<td width="8%">权限</td>
							<td width="8%">ID</td>
							<td>名称</td>
							<td>访问地址</td>
							<td>显示状态</td>
						</tr>
<?php
echo $this->listContent;
?>
					</table>
					<table class="controlTable">
						<tr>
							<td align="left">
								<input type="button" name="all" id="all" value="全选" class="button" onclick="$('.selectCheckBox').attr('checked', true);"/>
								<input type="button" name="cancel" id="cancel" value="取消" class="button" onclick="$('.selectCheckBox').attr('checked', false);"/>
								<input name="menuBtn" type="button" class="button" id="menuBtn" onclick="return setMenu(this);" value="保存选中菜单权限"/></td>
							<td align="right"></td>
						</tr>
					</table>
				</form>
<script language="javascript">
function setMenu(btn)
{
	var menuIds = '';
	$(".selectCheckBox").each(function(i){
		menuIds += menuIds != '' && this.checked == true ? ',' : '';
		menuIds += this.checked == true ? this.value : '';
	});
    var url = '<?php echo $this->projectUrl(array('action'=>'menu-save', 'roleId'=>$this->roleId, 'menuType'=>$this->menuType), NULL, false);?>'+'?rand/' + Math.random();

	btn.value = '正在保存中...';
	btn.disabled = true;
	$.ajax({
		type: "POST",
		url: url,
		dataType: "json",
		data: "menuIds=" + menuIds,
		async: true,
		success: function(result){
			btn.value = result.message;
			btn.disabled = false;
			setTimeout(function(){btn.value = '保存选中菜单权限';}, 1000);
			if (result.status == 0) {
				var isSelect = $(".isSelect");
				var selectCheckBox = $(".selectCheckBox");
				for(key in selectCheckBox) {
					if (selectCheckBox[key].checked == true) {
						isSelect[key].innerHTML = '√';
					} else {
						isSelect[key].innerHTML = '×';
					}
				}
			}
		} 
	});

}
</script>
<script language="javascript">
$(".selectCheckBox").click(function(){
	var id = $(this).attr('dbid');
	var currParentIds = $(this).attr('parentIds').split(',');
	var checked = this.checked;

	$(".selectCheckBox").each(function(i){
		//设置全部子目录
		var parentIds = $(this).attr('parentIds').split(',');
		for(i = 0; i <= parentIds.length - 1; i++) {
			if (parentIds[i] == id) {
				this.checked = checked;
				break;	
			}
		}

		//设置全部父目录
		if (checked == true) {
			for(i = 0; i <= currParentIds.length - 1; i++) {
				if (currParentIds[i] == $(this).attr('dbid')) {
					this.checked = checked;
					break;	
				}
			}
		}
	});

});
</script>